The present invention relates to a recompiling or recompilation method for generating object codes upon modification of a source program by making use of the result of previous compilation of the source program.
With "optimization in a compiler", a variety of program transformations are performed on a source program for the purpose of generating object programs capable of being executed at a higher speed. The run or execution performance of the object program generated by the compiler on a computer depends in large part on the performance or technique of the optimization processing. Accordingly, various devices or tools have been proposed in recent years in an effort to enhance or increase the ability of the compiler in performing the optimization processing. However, at the same time, it is to be noted that the optimization processing is very complicated and that the time taken for the optimization processing, and hence the time involved in the compilation, has increased significantly. Under the circumstances, as a measure for reducing the time taken for compilation (recompilation) of a source program undergone modification, a procedure of automated recompilation is known according to which, upon first or initial compilation of a source program, the procedures in the source program, which are the minimum units for the compilation and which are also referred to as subroutines, functions or the like, are separately compiled to obtain object program portions corresponding to the associated procedures, respectively, which object program portions are then combined together for execution. The object program portions obtained for the individual procedures, respectively, are saved separately, so that, when any one of the procedures in the original source program has been modified, recompilation is effected in such a manner that only the procedures which have undergone modification are recompiled, while for the procedures which have undergone no modification, the corresponding object program portions obtained previously are reused. According to a known technique for automating the execution of the procedures necessitating the recompilation (automated recompilation technique), the date of modification of each procedure is compared with the date of generation of the object program, and a decision is made that the recompilation is necessary when the former is a newer procedure than the latter. In this conjunction, reference may be made, for example, to "Software-Practice and Experience", Vol. 9, pp. 255-265 (1979).
The above mentioned technique can be applied only to such a case in which the compiler does not execute inter-procedural optimization, which is the optimization to be performed across a plurality of procedures in the source program. When the inter-procedural optimization is to be effectuated by the compiler, modification of a given one of the procedures exerts influence on a plurality of the other procedures taking part in the optimization. Consequently, it becomes necessary to recompile not only the modified procedures, but also several unmodified procedures. Those of the unmodified procedures which the recompilation are determined in dependence on the contents of the inter-procedural optimization performed by the compiler. Accordingly, by recording the information concerning the inter-procedural optimization carried out by the compiler, it is possible to extract automatically only the procedures that are to be recompiled even when the inter-procedural optimization has been performed, thereby allowing only the extracted procedures to be recompiled, as is disclosed in "ACM, Proceedings of the SIGPLAN 86 Symposium on Compiler Construction": SIGPLAN Notices, Vol. 21, No. 7 (July 1986), pp. 58-67.
According to the methods mentioned above, when an optimization processing is performed on individual procedures, inter-procedural data flow conditions, which are conditions on data flow of information across a procedure required for application of the optimization to the procedure, is recorded for the procedure. Data flow information represents where the value of a valuable is modified or used. Upon recompilation, new inter-procedural data flow information is extracted for the procedures in the modified program, whereon a decision on each procedure is made as to whether or not the new inter-procedural data flow information satisfies the inter-procedural data flow condition previously stored for the procedure. If the condition is satisfied, it can then be determined that the inter-procedural optimization processing carried out for the procedure in the original compilation is capable of being applied to that procedure even after the program modification. Accordingly, instead of recompiling the procedure which satisfies the inter-procedural data flow condition even after modification of the program as mentioned above, the object program portion generated for that procedure in the original compilation can be reused, while the other procedures which can not satisfy the abovementioned condition are recompiled on the basis of the new inter-procedural data flow information.
As another technique for reducing the processings involved in a recompilation, there can be mentioned an incremental compilation according to which intermediate codes obtained through syntax analysis processing performed on a source program to be compiled are held or saved, wherein when the source program is to be recompiled after modification thereof, only the program statements which have undergone modification are again analyzed with respect to syntax, while for the other program statements, the intermediate codes obtained in the original compilation are reused. In this manner, the amounts of the objectives for the syntax analysis processing can be reduced. Since the syntax analysis is inherently a local processing, it is relatively easy to reprocess only the modified portions mentioned above. This technique is reported in "ACM, Proceedings of the SIGPLAN 84 Symposium on Compiler Construction": SIGPLAN Notices, Vol. 19, No. 5 (June 1984), pp. 122-131.